package com.prs.crm.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author JohnLan
 * @time：2012-11-22 
 * @version 1.0
 * 类说明  日期工具类
 */

public class Datetools {
	
	Date date=new Date();
	SimpleDateFormat sf=new SimpleDateFormat("yyyyMMdd");
	
	
	 SimpleDateFormat sf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	  
//	 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	 

	
	
	/**
	 * 判断日期是否在所规定日期范围内
	 * @return
	 */
	public int getcurrent(Date startdate,Date enddate)
	{		
		 Date cure=new Date();
		 if ((startdate.getTime() > cure.getTime())&&(enddate.getTime() < cure.getTime())) {//满足需求
            return 1;
         } 	
		return  0;
	}

	/**
	 * 判断日期是否在所规定日期范围内
	 * @return
	 */
	public int getcurrentA(String a,String b)
	{
		 Date startdate=null;;
		 Date enddate =null;
		try {
			startdate = sf1.parse(a);
			enddate  = sf1.parse(b);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
		 Date cure=new Date();
		 if ((startdate.getTime() > cure.getTime())&&(enddate.getTime() < cure.getTime())) {//满足需求
            return 1;
         } 	
		return  0;
	}
	
	
	/**
	 * 判断日期是否在所规定日期之前
	 * @return
	 */
	public int getcurrentB(String a)
	{	
		Date startdate=null;
		try {
			startdate = sf1.parse(a);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		 Date cure=new Date();
		 if ((startdate.getTime() < cure.getTime())) {//满足需求
            return 1;
         } 	
		return  0;
	}

	
	/**
	 * 判断日期是否在所规定日期后
	 * @return
	 */
	public int getcurrentC(String a)
	{		
		Date startdate=null;
		try {
			startdate = sf1.parse(a);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		 Date cure=new Date();
		 if ((startdate.getTime() > cure.getTime())) {//满足需求
            return 1;
         } 	
		return  0;
	}

	
	/**
	 * 时间转换成字符串
	 * @return
	 */
	public String getstrTime(Date date)
	{	
		return sf1.format(date);
	}
	
}
